//
//  social.js
//
//  Cameron Lerch
//  Sponsored by Brightflock: http://brightflock.com
//

function Social() {
};

Social.prototype.available = function(callback) {
    cordova.exec(function(avail) {
        callback(avail ? true : false);
    }, null, "Social", "available", []);
};

Social.prototype.share = function(message, url, image) {
    cordova.exec(null, null, "Social", "share", [message, image, url]);
};

Social.install = function() {
    if (!window.plugins) {
        window.plugins = {};    
    }

    window.plugins.social = new Social();
    return window.plugins.social;
};

cordova.addConstructor(Social.install);


function setUpSocialLinks() {
    // Twitter
    $('li.twit a').click(function(event) {
        window.open(twitterUrl, '_blank', 'location=yes');
        event.preventDefault();
    });
    // Facebook
    $('li.face a').click(function(event) {
        window.open(facebookUrl, '_blank', 'location=yes');
        event.preventDefault();
    });
    // Twitter
    $('li.tube a').click(function(event) {
        window.open(youtubeChannelUrl, '_blank', 'location=yes');
        event.preventDefault();
    });
    // Twitter
    $('li.pica a').click(function(event) {
        window.open(picasaUrl, '_blank', 'location=yes');
        event.preventDefault();
    });
}

function shareEvent(title, urlToShare) {
    shareTitle( title ,   urlToShare );
}

function shareTitle(title, url){
    title = title.trim();
    url = url.trim();
    window.plugins.social.share(title + ' - ' + url, '', url);
}


